home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
os2
/
e33el2.zip
/
emacs
/
19.33
/
lisp
/
edt-mapper.el
< prev
next >
Wrap
Lisp/Scheme
|
1996-01-20
|
14KB
|
406 lines
;;; edt-mapper.el --- Create an EDT LK-201 Map File for X-Windows Emacs
;; Copyright (C) 1994, 1995 Free Software Foundation, Inc.
;; Author: Kevin Gallagher <kgallagh@spd.dsccc.com>
;; Maintainer: Kevin Gallagher <kgallagh@spd.dsccc.com>
;; Keywords: emulations
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;; This emacs lisp program can be used to create an emacs lisp file
;; that defines the mapping of the user's keyboard under X-Windows to
;; the LK-201 keyboard function keys and keypad keys (around which
;; EDT has been designed). Please read the "Usage" AND "Known
;; Problems" sections before attempting to run this program. (The
;; design of this file, edt-mapper.el, was heavily influenced by
;; tpu-mapper.el.)
;;; Usage:
;; Simply load this file into the X-Windows version of emacs (version 19)
;; using the following command.
;; emacs -q -l edt-mapper.el
;; The "-q" option prevents loading of your .emacs file (commands therein
;; might confuse this program).
;; An instruction screen showing the typical LK-201 terminal functions keys
;; will be displayed, and you will be prompted to press the keys on your
;; keyboard which you want to emulate the corresponding LK-201 keys.
;; Finally, you will be prompted for the name of the file to store
;; the key definitions. If you chose the default, it will be found
;; and loaded automatically when the EDT emulation is started. If
;; you specify a different file name, you will need to set the
;; variable "edt-xkeys-file" before starting the EDT emulation.
;; Here's how you might go about doing that in your .emacs file.
;; (setq edt-xkeys-file (expand-file-name "~/.my-emacs-x-keys"))
;;; Known Problems:
;; Sometimes, edt-mapper will ignore a key you press, and just continue to
;; prompt for the same key. This can happen when your window manager sucks
;; up the key and doesn't pass it on to emacs, or it could be an emacs bug.
;; Either way, there's nothing that edt-mapper can do about it. You must
;; press RETURN, to skip the current key and continue. Later, you and/or
;; your local X guru can try to figure out why the key is being ignored.
;; ====================================================================
;;;
;;; Make sure we're running X-windows and Emacs version 19
;;;
(cond
((not (and window-system (not (string-lessp emacs-version "19"))))
(insert "
Whoa! This isn't going to work...
You must run edt-mapper.el under X-windows and Emacs version 19.
Press any key to exit. ")
(sit-for 600)
(kill-emacs t)))
;;;
;;; Decide whether we're running GNU or Lucid emacs.
;;;
(defconst edt-lucid-emacs19-p (string-match "Lucid" emacs-version)
"Non-NIL if we are running Lucid Emacs version 19.")
;;;
;;; Key variables
;;;
(defvar edt-key nil)
(defvar edt-enter nil)
(defvar edt-return nil)
(defvar edt-key-seq nil)
(defvar edt-enter-seq nil)
(defvar edt-return-seq nil)
;;;
;;; Make sure the window is big enough to display the instructions
;;;
(if edt-lucid-emacs19-p (set-screen-size nil 80 36)
(set-frame-size (selected-frame) 80 36))
;;;
;;; Create buffers - Directions and Keys
;;;
(if (not (get-buffer "Directions")) (generate-new-buffer "Directions"))
(if (not (get-buffer "Keys")) (generate-new-buffer "Keys"))
;;;
;;; Put header in the Keys buffer
;;;
(set-buffer "Keys")
(insert "\
;;
;; Key definitions for the EDT emulation within GNU Emacs
;;
(defconst *EDT-keys*
'(
")
;;;
;;; Display directions
;;;
(switch-to-buffer "Directions")
(insert "
EDT MAPPER
You will be asked to press keys to create a custom mapping (under
X-Windows) of your keypad keys and function keys so that they can emulate
the LK-201 keypad and function keys or the subset of keys found on a
VT-100 series terminal keyboard. (The LK-201 keyboard is the standard
keyboard attached to VT-200 series terminals, and above.)
Sometimes, edt-mapper will ignore a key you press, and just continue to
prompt for the same key. This can happen when your window manager sucks
up the key and doesn't pass it on to emacs, or it could be an emacs bug.
Either way, there's nothing that edt-mapper can do about it. You must
press RETURN, to skip the current key and continue. Later, you and/or
your local X guru can try to figure out why the key is being ignored.
Start by pressing the RETURN key, and continue by pressing the keys
specified in the mini-buffer. If you want to entirely omit a key,
because your keyboard does not have a corresponding key, for example,
just press RETURN at the prompt.
")
(delete-other-windows)
;;;
;;; Save <CR> for future reference
;;;
(cond
(edt-lucid-emacs19-p
(setq edt-return-seq (read-key-sequence "Hit carriage-return <CR> to continue "))
(setq edt-return (concat "[" (format "%s" (event-key (aref edt-return-seq 0))) "]")))
(t
(message "Hit carriage-return <CR> to continue ")
(setq edt-return-seq (read-event))
(setq edt-return (concat "[" (format "%s" edt-return-seq) "]"))))
;;;
;;; Display Keypad Diagram and Begin Prompting for Keys
;;;
(set-buffer "Directions")
(delete-region (point-min) (point-max))
(insert "
PRESS THE KEY SPECIFIED IN THE MINIBUFFER BELOW.
Here's a picture of the standard LK-201 keypad for reference:
_______________________ _______________________________
| HELP | DO | | F17 | F18 | F19 | F20 |
| | | | | | | |
|_______|_______________| |_______|_______|_______|_______|
_______________________ _______________________________
| FIND |INSERT |REMOVE | | PF1 | PF2 | PF3 | PF4 |
| | | | | | | | |
|_______|_______|_______| |_______|_______|_______|_______|
|SELECT |PREVIOU| NEXT | | KP7 | KP8 | KP9 | KP- |
| | | | | | | | |
|_______|_______|_______| |_______|_______|_______|_______|
| UP | | KP4 | KP5 | KP6 | KP, |
| | | | | | |
_______|_______|_______ |_______|_______|_______|_______|
| LEFT | DOWN | RIGHT | | KP1 | KP2 | KP3 | |
| | | | | | | | |
|_______|_______|_______| |_______|_______|_______| KPE |
| KP0 | KPP | |
| | | |
|_______________|_______|_______|
")
;;;
;;; Key mapping functions
;;;
(defun edt-lucid-map-key (ident descrip func gold-func)
(interactive)
(setq edt-key-seq (read-key-sequence (format "Press %s%s: " ident descrip)))
(setq edt-key (concat "[" (format "%s" (event-key (aref edt-key-seq 0))) "]"))
(cond ((not (equal edt-key edt-return))
(set-buffer "Keys")
(insert (format " (\"%s\" . %s)\n" ident edt-key))
(set-buffer "Directions"))
;; bogosity to get next prompt to come up, if the user hits <C